import HttpClient from '../../utils/httpClient';

export function getDictByCode(code, success, error) {
  HttpClient.request({
    url: `/dict/findAll/${code}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function createDict(data, success, error) {
  HttpClient.request({
    method: 'post',
    url: '/dict/create',
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function dictDetail(id, success, error) {
  HttpClient.request({
    url: `/dict/detail/${id}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function updateDict(id, data, success, error) {
  HttpClient.request({
    method: 'put',
    url: `/dict/update/${id}`,
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function deleteDict(id, success, error) {
  HttpClient.request({
    method: 'delete',
    url: `/dict/delete/${id}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}
